Skip to content

gen_stub: support use statements in stub files#21784

Merged
DanielEScherzer merged 1 commit intophp:masterfrom
GromNaN:fix-gen-stub-use-statements
Apr 17, 2026
Merged

gen_stub: support use statements in stub files#21784
DanielEScherzer merged 1 commit intophp:masterfrom
GromNaN:fix-gen-stub-use-statements

Conversation

@GromNaN
Copy link
Copy Markdown
Member

@GromNaN GromNaN commented Apr 17, 2026

Fix a bug in build/gen_stub.php: use and use group statements in stub files caused an "Unexpected node Stmt_Use" exception. Since NameResolver already resolves names to their fully qualified form before handleStatements() runs, these nodes can be skipped.

Copy link
Copy Markdown
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems harmless. But @kocsismate should merge as he's codeowner.

Copy link
Copy Markdown
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept LGTM.

Comment thread build/gen_stub.php Outdated
@GromNaN GromNaN force-pushed the fix-gen-stub-use-statements branch from 7a158af to 0e10d2e Compare April 17, 2026 20:33
@kocsismate
Copy link
Copy Markdown
Member

Sorry, please rebase your branch, I've just merged your other PR :)

Stmt\Use_ and Stmt\GroupUse nodes were not handled in handleStatements(),
causing an "Unexpected node" exception when use statements appeared in
stub files. Since NameResolver resolves all names to their fully qualified
form before handleStatements() runs, these nodes can simply be skipped.
@GromNaN GromNaN force-pushed the fix-gen-stub-use-statements branch from 0e10d2e to 029343e Compare April 17, 2026 20:57
@GromNaN
Copy link
Copy Markdown
Member Author

GromNaN commented Apr 17, 2026

PR rebased. The conflict was bound to happen.

Copy link
Copy Markdown
Member

@DanielEScherzer DanielEScherzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, leaving to @kocsismate for final approval

@kocsismate
Copy link
Copy Markdown
Member

I'm leaving for sleep, so anyone can feel free to merge it once the tests pass. I can do it in the morning :)

@DanielEScherzer
Copy link
Copy Markdown
Member

I'm leaving for sleep, so anyone can feel free to merge it once the tests pass. I can do it in the morning :)

I can handle merging since this looks good to you

@DanielEScherzer DanielEScherzer merged commit fa5ab4f into php:master Apr 17, 2026
19 checks passed
@GromNaN GromNaN deleted the fix-gen-stub-use-statements branch April 18, 2026 08:39
arshidkv12 pushed a commit to arshidkv12/php-src that referenced this pull request Apr 18, 2026
Stmt\Use_ and Stmt\GroupUse nodes were not handled in handleStatements(),
causing an "Unexpected node" exception when use statements appeared in
stub files. Since NameResolver resolves all names to their fully qualified
form before handleStatements() runs, these nodes can simply be skipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants